<?php

namespace app\web\command;

use app\common\util\Tools;
use think\console\Input;
use think\console\Output;
use think\facade\Log;

class UserTest extends CommonTest
{

    //再命令窗口中执行“php think interfaceWeb-UserTest”
    protected function configure()
    {
        $this->setName('interfaceWeb-UserTest')
            ->setDescription('接口测试');
    }

    public function execute(Input $input, Output $output)
    {
        parent::execute($input, $output);

        /** 用户相关 */
//        Route::any('web/member/getInfo', 'web/user/getInfo');                                       // 获取用户信息
//        $data = Tools::curl($this->url . "web/member/getInfo", json_encode(["token" => "$this->token"]));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";
//
//        //Route::any('web/member/updateUser', 'web/user/updateUser');                                                             // 更新用户信息
//        $data = Tools::curl($this->url . "web/member/updateUser", json_encode(["token" => "$this->token", "nickname" => "song"]));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";
//
//        //Route::any('web/member/changePassword', 'web/user/changePassword');                                                     // 修改用户密码
//        $cData = ["token" => "$this->token", "oldPassword" => "123456a", "password" => "1234567a", "comfirmPassword" => "1234567a"];
//        $data = Tools::curl($this->url . "web/member/changePassword", json_encode($cData));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('web/member/getBuyProduct', 'web/user/getBuyProduct');                                                       // 已购买的产品
        $data = Tools::curl($this->url . "web/member/getBuyProduct", json_encode(["token" => "$this->token", "time" => 1, "search" => ""]));
        Log::write("post". var_export($data,true));
        echo print_r(json_decode($data,1)) . "\n\n";
        echo $data . "\n\n";

        //Route::any('web/member/updateProduct', 'web/product/updateProduct');                                                       // 更新录入产品实例信息
//        $uData = ["token" => "$this->token", "id" => 2, "name" => "测试", "original" => "sdfsdf", "appId" => "232dfdsf", "secret" => "sdfdsfsdf", "version" => "1.0.0"];
//        $data = Tools::curl($this->url . "web/member/updateProduct", json_encode($uData));
//        Log::write("post". var_export($data,true));
//        echo print_r(json_decode($data,1)) . "\n\n";
//        echo $data . "\n\n";
    }
}
